#include <QApplication>

#include "cvMatConversionQImage.h"

#include <QWidget>
#include <QLabel>
#include <QDebug>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

#if 0 //测试QImage2Mat
    QPixmap map ;
    map .load("../../image/test.jpg");
    QImage img = map.toImage();
    cv::Mat mat = cvMatConversionQImage::QImage2Mat(img);
    QImage img2 = cvMatConversionQImage::Mat2QImage(mat);
    QPixmap map2 = QPixmap::fromImage(img2);
    QLabel label;
    label.setPixmap(map2);
#else //测试Mat2QImage
    cv::Mat mat = cv::imread("/home/pi/work/develop/Mat_Image_conversion/image/test.jpg");
    if(mat.empty())
    {
        qDebug() <<"打开图片失败";
        return 0;
    }
    QImage img = cvMatConversionQImage::Mat2QImage(mat);
    QPixmap map = QPixmap::fromImage(img);
    QLabel label;
    label.setPixmap(map);
#endif
    label.show();
    //cv::imshow("aaa", mat);
    return a.exec();
}
